﻿package test.ui {
	import gear.core.Game;
	import gear.net.LibData;
	import gear.net.RESManager;
	import gear.net.SWFLoader;
	import gear.ui.controls.GTextArea;
	import gear.ui.data.GTextAreaData;

	import flash.events.Event;
	import flash.events.TextEvent;

	/**
	 * @version 20100115
	 * @author bright
	 */
	[SWF(width=1000,height=570,backgroundColor=0x003399,frameRate=30)]
	public class TestGTextArea extends Game {
		override protected function startup() : void {
			RESManager.instance.add(new SWFLoader(new LibData("assets/ui.swf")));
			RESManager.instance.addEventListener(Event.COMPLETE, completeHandler);
			RESManager.instance.load();
		}

		private function completeHandler(event : Event) : void {
			var data : GTextAreaData = new GTextAreaData();
			data.styleSheet.parseCSS(".blue{color:#FFFF00}");
			data.x = 10;
			data.y = 50;
			data.width = 320;
			data.height = 240;
			data.selectable = true;
			data.maxLines = 5;
			var ta : GTextArea = new GTextArea(data);
			ta.appendHtmlText("<a href='event:hello'>hello</a>");
			addChild(ta);
			ta.textField.addEventListener(TextEvent.LINK, linkHandler);
		}

		private function linkHandler(event : TextEvent) : void {
			trace(event.text);
		}
	}
}
